{include file="common/head"}
</head>
<body >
<!--startprint-->
<div class="container-fluid" style="max-width: 400px;">

    <div class="" style="font-size: 1rem;">
        <div style="font-size:1.3rem;font-weight: bold;">餐桌号：{$order.table_id_name}</div>
        <div>订单流水：{$order.order_no}</div>
        <div>下单人：{$list[0]['creater_name']}</div>
        <div>下单时间：{$order.create_time}</div>
        <div>状态：{$order['status_name']}</div>
    </div>

    <table class="table table-sm table-hover" style="width: initial;min-width: 100%;">
        <thead >
            <th>序号</th>
            <th>商品名称</th>
            <th>价格</th>
            <th>数量</th>
            <th>小计</th>
        </thead>
        <tbody>
            {foreach $list as $k=>$kv}
            <tr>
                <td>{$k+1}</td>
                <td style="max-width: 240px;">
                    <div>{$kv['name']}</div> 
                    <div class="text-info">{$kv['name2']}</div>
                </td>
                <td>{$kv['price']}</td>
                <td>x{$kv['num']}</td>
                <td>{$kv['total']}</td>
            </tr>
            {/foreach}
            <tr >
                <td></td>
                <td></td>
                <td>Total</td>
                <td>{$num}</td>
                <td>{$sum}</td>
            </tr>
        </tbody>    
    </table>


</div>
<!--endprint-->
<div class="text-center">
    <button class="btn btn-sm btn-primary" type="button" onclick="printpage();">
        <span class="bi-printer"></span> Print
    </button>
</div>

<div style="height:50px;text-align: center;color:#999"></div>
</body>

<script type="text/javascript">

  $(document).ready(function(){



  })

    function printpage(){
      let oldStr = window.document.body.innerHTML; // 获取body的内容
      let start = "<!--startprint-->"; // 开始打印标识, 17个字符
      let end = "<!--endprint-->"; // 结束打印标识
      let newStr = oldStr.substr(oldStr.indexOf(start) + 17); // 截取开始打印标识之后的内容
      newStr = newStr.substring(0, newStr.indexOf(end)); // 截取开始打印标识和结束打印标识之间的内容
      window.document.body.innerHTML = newStr; // 把需要打印的指定内容赋给body
      window.print(); // 调用浏览器的打印功能打印指定区域
      window.document.body.innerHTML = oldStr; // body替换为原来的内容
    }
</script>


</body>
</html>
